/*
 * 在Neutronia 王国,货币单位是tvarp,收入所得税的计算方式如下:
 * 5000 tvarps: 不收税
 * 5001~15000 tvarps: 10%
 * 15001~35000 tvarps:15%
 * 35000 tvarps 以上: 20%
 * 编写一个程序,使用循环来要求用户输入收入,并报告所得税.当用户输入负数或者飞数字时,循环结束.
 *
*/

#include<iostream>
#include<cctype>
#include<istream>
int main()
{
    using namespace std;
    int inCome;
    cout << "Please enter your income:"<<endl;
    cin>>inCome;
    while( !cin.fail()&& inCome>=0)         //使用cin.fail()来进行输入检查
    {
        cin.clear();                        //清除标志
        double tax=0.0;
        if(inCome>5000)
            tax+=(inCome-5000)*0.1;
        if(inCome>15000)
            tax+=(inCome-15000)*0.15;
        if(inCome>35000)
            tax+= (inCome-35000)*0.2;
        cout<<"When The Income Is "<<inCome<<",The Income Tax Is "<<tax<<".\n";
        cin>>inCome;
    }
    return 0;
}
